<template>
  <el-container>
    <FormPanel ref="formPanel" :list="formList" :cols="1" :labelWidth="110" formType="show" />
  </el-container>
</template>
<script>
export default {
  name: 'claimVal',
  props: {
    fromData: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      formList: this.createFormList()
    };
  },
  watch: {
    fromData: {
      handler(obj) {
        for (let [key, value] of Object.entries(obj)) {
          this.formList.some(item => {
            if (item.fieldName === key) {
              item.initialValue = value;
              return true;
            }
          });
        }
      },

      immediate: true
    }
  },
  mounted() {},
  methods: {
    createFormList() {
      return [
        {
          type: 'INPUT',
          label: '工时费(索赔)',
          fieldName: 'labourAmountS',
          placeholder: '',
          initialValue: 0.0,
          precision: 2,
          numberFormat: true
        },
        {
          type: 'INPUT',
          label: '维修材料费(索赔)',
          fieldName: 'repairPartAmountS',
          placeholder: '',
          initialValue: 0.0,
          precision: 2,
          numberFormat: true
        },
        {
          type: 'INPUT',
          label: '销售材料(索赔)',
          fieldName: 'salePartAmountS',
          placeholder: '',
          initialValue: 0.0,
          hidden: true,
          precision: 2,
          numberFormat: true
        },
        {
          type: 'INPUT',
          label: '附加项目(索赔)',
          fieldName: 'addItemAmountS',
          placeholder: '',
          initialValue: 0.0,
          precision: 2,
          numberFormat: true
        },
        {
          type: 'INPUT',
          label: '维修金额(索赔)',
          fieldName: 'totalAmountS',
          placeholder: '',
          initialValue: 0.0,
          precision: 2,
          numberFormat: true
        },
        {
          type: 'INPUT',
          label: '预估金额(索赔)',
          fieldName: 'estimateAmountS',
          placeholder: '',
          initialValue: 0.0,
          precision: 2,
          numberFormat: true
        }
      ];
    }
  }
};
</script>
<style lang="less" scoped></style>
